﻿using System.Threading.Tasks;

namespace Sidvall.AuthorizationManager.Model.Local.DataPortalManagers
{
    public static partial class AuthorizationScopeResourceItemClaimManager
    {
        #region DeleteItemsAsync

        static partial void OnBeforeDelete(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnBeforeDelete(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope transactionScope);
        static partial void OnBeforeDelete(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope transactionScope, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterDelete(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnAfterDelete(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope transactionScope);
        static partial void OnAfterDelete(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope transactionScope, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task DeleteItemsAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, global::Sidvall.Data.DeleteCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeDelete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (Sidvall.Data.ITransactionScope tr = SystemContext.Current.DataPortalStrategy.GetTransactionScope(dataPortalContext))
                        {
                            OnBeforeDelete(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                                {
                                    OnBeforeDelete(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                                    {
                                        await manager.DeleteItemsAsync(dataPortalContext).ConfigureAwait(false);
                                    }
                                    OnAfterDelete(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                }
                            }
                            OnAfterDelete(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (tr != null)
                                tr.Complete();
                        }
                    }
                    OnAfterDelete(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region NewItemAsync

        static partial void OnBeforeNewItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext);
        static partial void OnBeforeNewItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterNewItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext);
        static partial void OnAfterNewItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        public static async Task NewItemAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeNewItem(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                        {
                            OnBeforeNewItem(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                await manager.NewItemAsync(dataPortalContext).ConfigureAwait(false);
                                var data = dataPortalContext.ResultValueItem;
                                if (data != null)
                                    dataPortalContext.ResultValueItem = dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.Copy(data, Sidvall.Data.CopySettings.FullCopyCurrent(Sidvall.Data.DataRowContextOption.None, Sidvall.Data.DataRowState.Added));
                                else
                                    dataPortalContext.ResultValueItem = null;
                            }
                            OnAfterNewItem(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                        }
                    }
                    OnAfterNewItem(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region NewItemsAsync

        static partial void OnBeforeNewItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext);
        static partial void OnBeforeNewItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterNewItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext);
        static partial void OnAfterNewItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task NewItemsAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.CreateCriteria> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeNewItems(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                        {
                            OnBeforeNewItems(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                await manager.NewItemsAsync(dataPortalContext).ConfigureAwait(false);
                                var data = dataPortalContext.ResultValueList;
                                if (data != null)
                                    dataPortalContext.ResultValueListProvider = dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.Copy(data, Sidvall.Data.CopySettings.FullCopyCurrent(Sidvall.Data.DataRowContextOption.None, Sidvall.Data.DataRowState.Added));
                                else
                                    dataPortalContext.ResultValueListProvider = null;
                            }
                            OnAfterNewItems(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                        }
                    }
                    OnAfterNewItems(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region GetItemAsync

        static partial void OnBeforeGetItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext);
        static partial void OnBeforeGetItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterGetItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext);
        static partial void OnAfterGetItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task GetItemAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeGetItem(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                        {
                            OnBeforeGetItem(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                await manager.GetItemAsync(dataPortalContext).ConfigureAwait(false);
                                var data = dataPortalContext.ResultValueItem;
                                if (data != null)
                                    dataPortalContext.ResultValueItem = dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.Copy(data, Sidvall.Data.CopySettings.FullCopyCurrent(Sidvall.Data.DataRowContextOption.None, Sidvall.Data.DataRowState.Unchanged));
                                else
                                    dataPortalContext.ResultValueItem = null;
                            }
                            OnAfterGetItem(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                        }
                    }
                    OnAfterGetItem(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region GetItemsAsync

        static partial void OnBeforeGetItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchListCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext);
        static partial void OnBeforeGetItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchListCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterGetItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchListCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext);
        static partial void OnAfterGetItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchListCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task GetItemsAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, global::Sidvall.Data.FetchListCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceItemClaimRelation>> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeGetItems(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                        {
                            OnBeforeGetItems(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                await manager.GetItemsAsync(dataPortalContext).ConfigureAwait(false);
                                var data = dataPortalContext.ResultValueList;
                                dataPortalContext.ResultValueListProvider = (Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>)dataPortalManager.ResourceFactory.CreateItems(global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceItemClaim);
                                if (data != null)
                                    dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.Import(dataPortalContext.ResultValueList, data, dataPortalContext.TotalRowCount, Sidvall.Data.CopySettings.FullCopyCurrent(Sidvall.Data.DataRowContextOption.None, Sidvall.Data.DataRowState.Unchanged));
                            }
                            OnAfterGetItems(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                        }
                    }
                    OnAfterGetItems(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region GetItemCountAsync

        static partial void OnBeforeGetItemCount(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<long, global::Sidvall.Data.FetchCountCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnBeforeGetItemCount(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<long, global::Sidvall.Data.FetchCountCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterGetItemCount(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<long, global::Sidvall.Data.FetchCountCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnAfterGetItemCount(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<long, global::Sidvall.Data.FetchCountCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task GetItemCountAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<long, global::Sidvall.Data.FetchCountCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeGetItemCount(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                        {
                            OnBeforeGetItemCount(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                                await manager.GetItemCountAsync(dataPortalContext).ConfigureAwait(false);
                            OnAfterGetItemCount(dataPortalManager, dataPortalContext, manager);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                        }
                    }
                    OnAfterGetItemCount(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region SaveItemAsync

        static partial void OnBeforeSaveItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext);
        static partial void OnBeforeSaveItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnBeforeSaveItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterSaveItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext);
        static partial void OnAfterSaveItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnAfterSaveItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task SaveItemAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>> dataPortalContext)
        {
            global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim data = null;

            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeSaveItem(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (Sidvall.Data.ITransactionScope tr = SystemContext.Current.DataPortalStrategy.GetTransactionScope(dataPortalContext))
                        {
                            OnBeforeSaveItem(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                                {
                                    OnBeforeSaveItem(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                                    {
                                        await manager.SaveItemAsync(dataPortalContext).ConfigureAwait(false);
                                        data = dataPortalContext.ResultValueItem;
                                    }
                                    OnAfterSaveItem(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                }
                            }
                            OnAfterSaveItem(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (tr != null)
                                tr.Complete();
                        }
                        if (data != null)
                        {
                            dataPortalContext.ResultValueItem = dataPortalContext.OperationContext.Item;
                            if (dataPortalContext.ResultValueIsNewObject)
                                dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.Import(dataPortalContext.ResultValueItem, data, Sidvall.Data.CopySettings.FullMergeAll(Sidvall.Data.DataRowContextOption.None, null));
                            dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.AcceptChanges(dataPortalContext.ResultValueItem, dataPortalContext.AcceptChangesSettings);
                        }
                    }
                    OnAfterSaveItem(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region SaveItemsAsync

        static partial void OnBeforeSaveItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext);
        static partial void OnBeforeSaveItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnBeforeSaveItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterSaveItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext);
        static partial void OnAfterSaveItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnAfterSaveItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task SaveItemsAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim, Sidvall.Data.SaveContext<Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>>> dataPortalContext)
        {
            System.Collections.Generic.IEnumerable<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim> data = null;

            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeSaveItems(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (Sidvall.Data.ITransactionScope tr = SystemContext.Current.DataPortalStrategy.GetTransactionScope(dataPortalContext))
                        {
                            OnBeforeSaveItems(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                                {
                                    OnBeforeSaveItems(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                                    {
                                        await manager.SaveItemsAsync(dataPortalContext).ConfigureAwait(false);
                                        data = dataPortalContext.ResultValueList;
                                    }
                                    OnAfterSaveItems(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                }
                            }
                            OnAfterSaveItems(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (tr != null)
                                tr.Complete();
                        }
                        if (data != null)
                        {
                            dataPortalContext.ResultValueListProvider = dataPortalContext.OperationContext.Item;
                            if (dataPortalContext.ResultValueIsNewObject)
                                dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.Import(dataPortalContext.ResultValueList, data, dataPortalContext.TotalRowCount, Sidvall.Data.CopySettings.FullMergeAll(Sidvall.Data.DataRowContextOption.None, null));
                            dataPortalManager.GenericEntityFacade.AuthorizationScopeResourceItemClaimManager.AcceptChanges(dataPortalContext.ResultValueListProvider.DataItems, dataPortalContext.AcceptChangesSettings);
                        }
                        else if (dataPortalContext.Result != Sidvall.Business.DataPortalResult.Ok)
                        {
                            dataPortalContext.ResultValueListProvider = (Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItemClaim>)dataPortalManager.ResourceFactory.CreateItems(global::Sidvall.AuthorizationManager.Data.Model.DomainObjects.AuthorizationScopeResourceItemClaim);
                        }
                    }
                    OnAfterSaveItems(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region UpdateItemAsync

        static partial void OnBeforeUpdateItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnBeforeUpdateItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnBeforeUpdateItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterUpdateItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnAfterUpdateItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnAfterUpdateItem(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task UpdateItemAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<bool, Sidvall.Data.UpdateItemContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeUpdateItem(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (Sidvall.Data.ITransactionScope tr = SystemContext.Current.DataPortalStrategy.GetTransactionScope(dataPortalContext))
                        {
                            OnBeforeUpdateItem(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                                {
                                    OnBeforeUpdateItem(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                                    {
                                        await manager.UpdateItemAsync(dataPortalContext).ConfigureAwait(false);
                                    }
                                    OnAfterUpdateItem(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                }
                            }
                            OnAfterUpdateItem(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (tr != null)
                                tr.Complete();
                        }
                    }
                    OnAfterUpdateItem(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region UpdateItemsAsync

        static partial void OnBeforeUpdateItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnBeforeUpdateItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnBeforeUpdateItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterUpdateItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext);
        static partial void OnAfterUpdateItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnAfterUpdateItems(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public static async Task UpdateItemsAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<int, Sidvall.Data.UpdateItemsContext<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceItemClaimField>> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeUpdateItems(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (Sidvall.Data.ITransactionScope tr = SystemContext.Current.DataPortalStrategy.GetTransactionScope(dataPortalContext))
                        {
                            OnBeforeUpdateItems(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                                {
                                    OnBeforeUpdateItems(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                                    {
                                        await manager.UpdateItemsAsync(dataPortalContext).ConfigureAwait(false);
                                    }
                                    OnAfterUpdateItems(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                }
                            }
                            OnAfterUpdateItems(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (tr != null)
                                tr.Complete();
                        }
                    }
                    OnAfterUpdateItems(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
        #region ExecuteAsync

        static partial void OnBeforeExecute(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext);
        static partial void OnBeforeExecute(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnBeforeExecute(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        static partial void OnAfterExecute(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext);
        static partial void OnAfterExecute(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext, Sidvall.Data.ITransactionScope tr);
        static partial void OnAfterExecute(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext, Sidvall.Data.ITransactionScope tr, global::Sidvall.Data.IStorageManager manager);
        public static async Task ExecuteAsync(global::Sidvall.AuthorizationManager.Model.IDataPortalManager dataPortalManager, global::Sidvall.Business.DataPortalContext<global::Sidvall.Data.CommandCriteria, global::Sidvall.Data.CommandCriteria> dataPortalContext)
        {
            if (dataPortalContext == null)
                throw new System.ArgumentNullException(nameof(dataPortalContext));
            do
            {
                try
                {
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvoke(dataPortalManager, dataPortalContext);
                    OnBeforeExecute(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                    if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                    {
                        using (Sidvall.Data.ITransactionScope tr = SystemContext.Current.DataPortalStrategy.GetTransactionScope(dataPortalContext))
                        {
                            OnBeforeExecute(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (dataPortalContext.Result == Sidvall.Business.DataPortalResult.None)
                            {
                                using (global::Sidvall.Data.IStorageManager manager = SystemContext.Current.DataPortalStrategy.GetStorageManager(dataPortalContext))
                                {
                                    OnBeforeExecute(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                    await manager.ExecuteAsync(dataPortalContext).ConfigureAwait(false);
                                    OnAfterExecute(dataPortalManager, dataPortalContext, tr, manager);
                                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                                }
                            }
                            OnAfterExecute(dataPortalManager, dataPortalContext, tr);
                            await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                            if (tr != null)
                                tr.Complete();
                        }
                    }
                    OnAfterExecute(dataPortalManager, dataPortalContext);
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalInvokeComplete(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync().ConfigureAwait(false);
                }
                catch (System.Exception ex)
                {
                    dataPortalContext.Exception = ex;
                    global::Sidvall.AuthorizationManager.Model.Local.DataPortalEventManager.DataPortalException(dataPortalManager, dataPortalContext);
                    await dataPortalContext.DoTaskAsync(!dataPortalContext.Retry).ConfigureAwait(false);
                }
            } while (dataPortalContext.DoRetry());
        }

        #endregion
    }
}